﻿Imports Microsoft.VisualBasic
Imports System.Text.RegularExpressions
Imports System.Collections.Generic

Public Class clsDate
    '檢查日期(yyyy/mm/dd)
    Public Function CheckDate(ByVal sDate As String)
        Dim pattern As String = "([1-9]\d\d\d[-/]([0][13578]|[1][02])[-/](([0][1-9]|[12][\d])|[3][01]))|([1-9]\d\d\d)[-/]([0][13456789]|[1][012])[-/](([0][1-9]|[12][\d])|[3][0])|([1-9]\d([02468][048]|[13579][26])[-/][0][2][-/]([0][1-9]|[12][\d]))|([1-9]\d\d\d[-/][0][2][-/]([0][1-9]|[12][0-8]))"
        Dim re As Regex = New Regex(pattern, RegexOptions.IgnoreCase)
        Dim m As Match = re.Match(sDate)
        If m.Success Then
            If m.Value <> sDate Then Return False
        End If
        Return m.Success
    End Function
End Class

